package midlet;

import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

import components.IntroCanvas;

public class ClientApp extends MIDlet {
    //静态的实例对象

    public static ClientApp instance = null;

    public ClientApp() {
        instance = this;
        Display.getDisplay(this).setCurrent(new IntroCanvas());
    }

    /**
     * 退出应用程序
     */
    public static void exitMidlet() {
        try {
            instance.destroyApp(true);
            instance.notifyDestroyed();
            instance = null;
        } catch (Exception ex) {
            System.out.println("occur exception where call method exitMidlet " + ex.getMessage());
        }
    }

    public static void navigateTo(Displayable dis) {
        instance.navigate(dis);

    }

    public void navigate(Displayable dis) {
        Display.getDisplay(this).setCurrent(dis);
    }

    protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {
    }

    protected void pauseApp() {
    }

    protected void startApp() throws MIDletStateChangeException {
    }
}
